---
title: 'Share file dialog'
sidebarTitle: 'Share file'
description: 'Open a file sharing dialog in a Kotlin Multiplatform project'
---

import AndroidFileProviderSetup from '/snippets/android-fileprovider-setup.mdx'

<Check>Supported on Android and iOS targets</Check>

<div className="flex justify-center gap-6">
  <img height="200" width="200" noZoom src="/images/share-file-ios.png" />
  <img height="200" width="200" noZoom src="/images/share-file-android.png" />
</div>

## Open the share file dialog

The share file component provides a native interface for users to share files using their device's sharing options.

<CodeGroup>
```kotlin filekit-dialogs
val file = PlatformFile("/path/to/file.txt")
// share a single file
FileKit.shareFile(file)
// share multiple files
FileKit.shareFiles(listOf(file1, file2))
```

```kotlin filekit-dialogs-compose
val launcher = rememberShareFileLauncher()

Button(onClick = { 
    // share a single file
    launcher.launch(file)
    // share multiple files
    launcher.launch(listOf(file1, file2))
}) {
    Text("Share file")
}
```
</CodeGroup>

<Info>
Ensure the file you are sharing exists and is accessible. Sharing a non-existent file will result in an error.
</Info>

## Android setup

<AndroidFileProviderSetup />

3. When sharing files from custom locations, provide the `shareSettings` parameter with your app's FileProvider authority:

<CodeGroup>
```kotlin filekit-dialogs
val file = FileKit.filesDir / "my_file.txt"
FileKit.shareFile(
    file = file,
    shareSettings = FileKitShareSettings(
        authority = "${context.packageName}.fileprovider"
    )
)
```

```kotlin filekit-dialogs-compose
val launcher = rememberShareFileLauncher()

val file = FileKit.filesDir / "my_file.txt"
Button(onClick = { 
    launcher.launch(
        file = file,
        shareSettings = FileKitShareSettings(
            authority = "${context.packageName}.fileprovider"
        )
    )
}) {
    Text("Share file")
}
```
</CodeGroup>
